|
1
|
|
|
var chai = require('chai'); |
|
2
|
|
|
|
|
3
|
|
|
var config = require('../src/cli').config |
|
4
|
|
|
config.set({root: __dirname + '/fixtures'}) |
|
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
var cmsData = require('../src/cli').cmsData; |
|
7
|
|
|
var Manager = require('../src/cli').Manager; |
|
8
|
|
|
var fse = require('fs-extra'); |
|
9
|
|
|
|
|
10
|
|
|
describe('attributes', function() { |
|
11
|
|
|
before( function(done) { |
|
12
|
|
|
Manager.instance.init() |
|
13
|
|
|
.then(function () { |
|
14
|
|
|
Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles'] |
|
15
|
|
|
Manager.instance.updateList() |
|
16
|
|
|
|
|
17
|
|
|
this.fixture = { |
|
18
|
|
|
tag: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf8'), |
|
|
|
|
|
|
19
|
|
|
html: fse.readFileSync(__dirname + '/fixtures/templates/article.html', 'utf8'), |
|
|
|
|
|
|
20
|
|
|
json: fse.readJsonSync(__dirname + '/fixtures/data/article-1.json') |
|
|
|
|
|
|
21
|
|
|
} |
|
22
|
|
|
done() |
|
23
|
|
|
|
|
24
|
|
|
}.bind(this)) |
|
25
|
|
|
}); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* cmsData.values.removeDuplicate |
|
29
|
|
|
* |
|
30
|
|
|
*/ |
|
31
|
|
|
it('cmsData.values.removeDuplicate', function() { |
|
32
|
|
|
var newJson = cmsData.values.removeDuplicate(this.fixture.html, this.fixture.json) |
|
33
|
|
|
chai.expect(newJson.title).to.be.undefined; |
|
|
|
|
|
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* cmsData.attributes.sanitizeSourceAttribute |
|
38
|
|
|
* |
|
39
|
|
|
*/ |
|
40
|
|
|
it('cmsData.attributes.sanitizeSourceAttribute', function() { |
|
41
|
|
|
// not sure what it does |
|
42
|
|
|
}); |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* cmsData.attributes.getAll |
|
46
|
|
|
* |
|
47
|
|
|
*/ |
|
48
|
|
|
it('cmsData.attributes.getAll()', function(done) { |
|
49
|
|
|
var attributes = cmsData.attributes.getAll(this.fixture.tag, this.fixture.jsonArticle) |
|
50
|
|
|
chai.expect(attributes.sourceString).to.contain('select'); |
|
51
|
|
|
done(); |
|
52
|
|
|
}); |
|
53
|
|
|
}); |
|
54
|
|
|
|